<?xml version="1.0" encoding="UTF-8"?>

<!-- Copyright 2007 XBRL International. All Rights Reserved. -->

<link:linkbase
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:link="http://www.xbrl.org/2003/linkbase"
  xmlns:generic="http://xbrl.org/2008/generic"
  xmlns:va="http://xbrl.org/2008/assertion/value"
  xmlns:variable="http://xbrl.org/2008/variable"
  xmlns:cf="http://xbrl.org/2008/filter/concept"
  xmlns:crf="http://xbrl.org/2008/filter/concept-relation"
  xmlns:xfi="http://www.xbrl.org/2008/function/instance" 
  xmlns:label="http://xbrl.org/2008/label"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:test="http://abc.com/test"
  xmlns:xbrli="http://www.xbrl.org/2003/instance"

  xsi:schemaLocation="
  http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd
  http://xbrl.org/2008/generic ../../../core_schemas/generic-link.xsd
  http://xbrl.org/2008/formula ../../../core_schemas/formula.xsd
  http://xbrl.org/2008/variable ../../../core_schemas/variable.xsd
  http://xbrl.org/2008/filter/concept ../../../core_schemas/concept-filter.xsd
  http://xbrl.org/2008/filter/concept-relation ../../../core_schemas/concept-relation-filter.xsd
  http://xbrl.org/2008/label http://www.xbrl.org/2008/generic-label.xsd
  ">
  
  <link:arcroleRef arcroleURI="http://xbrl.org/arcrole/2008/element-label" xlink:href="http://www.xbrl.org/2008/generic-label.xsd#element-label" xlink:type="simple"/>
  <link:arcroleRef arcroleURI="http://xbrl.org/arcrole/2008/variable-set" xlink:href="../../../core_schemas/variable.xsd#variable-set" xlink:type="simple"/>
  <link:arcroleRef arcroleURI="http://xbrl.org/arcrole/2008/variable-filter" xlink:href="../../../core_schemas/variable.xsd#variable-filter" xlink:type="simple"/>
  <link:roleRef roleURI="http://www.xbrl.org/2008/role/link" xlink:href="../../../core_schemas/generic-link.xsd#standard-link-role" xlink:type="simple"/>
  <link:arcroleRef arcroleURI="http://xbrl.org/arcrole/2008/variable-set-precondition" xlink:href="../../../core_schemas/variable.xsd#variable-set-precondition" xlink:type="simple"/>  <link:roleRef roleURI="http://www.xbrl.org/2008/role/link" xlink:href="../../../core_schemas/generic-link.xsd#standard-link-role" xlink:type="simple"/>

  <generic:link xlink:type="extended"
    xlink:role="http://www.xbrl.org/2008/role/link">

    <va:valueAssertion xlink:type="resource" 
      xlink:label="calc-linkbase-assertion"
      id="calc-linkbase-assertion"
      aspectModel="non-dimensional" implicitFiltering="false" 
      test="$parent eq sum($weightedChildValues)" />

    <!-- general variable is sequence link roles of calculation arcs -->
    <variable:generalVariable xlink:type="resource" xlink:label="v_linkRole" bindAsSequence="false"
      select="$linkRole in xfi:linkbase-link-roles('http://www.xbrl.org/2003/arcrole/summation-item')" />

    <!--  Fact variables.  -->
    <variable:factVariable xlink:type="resource" xlink:label="v_parent"   bindAsSequence="false" />
    
    <!--  Family have same aspects as parent (except concept names), bound as sequence -->
    <variable:factVariable xlink:type="resource" xlink:label="v_family" bindAsSequence="true" />

    <!--  Arc from the calc-linkbase-assertion to the variables it depends on -->
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="calc-linkbase-assertion" xlink:to="v_linkRole" order="1.0"
      name="linkRole" />
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="calc-linkbase-assertion" xlink:to="v_parent" order="1.0"
      name="parent" />
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="calc-linkbase-assertion" xlink:to="v_family" order="1.0"
      name="family" />
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="calc-linkbase-assertion" xlink:to="v_weightedChildValues" order="1.0"
      name="weightedChildValues" />

    <!--  Arcs from variables to their concept filters -->
    <variable:variableFilterArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-filter" 
      complement="false" cover="true"
      xlink:from="v_family" xlink:to="f_family" order="1.0"/>

    <!-- cover concept aspect to allow family facts of different QNames in single sequence -->
    <cf:conceptSubstitutionGroup strict="false" xlink:type="resource" xlink:label="f_family">
      <cf:substitutionGroup><cf:qname>xbrli:item</cf:qname></cf:substitutionGroup>
    </cf:conceptSubstitutionGroup>

    <!-- general variable is sequence of relationship effective arc elements -->
    <variable:generalVariable xlink:type="resource" xlink:label="rels" bindAsSequence="true"
      select="xfi:concept-relationships(
                node-name($parent), 
                $linkRole,
                'http://www.xbrl.org/2003/arcrole/summation-item',
                'child')"  />
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="calc-linkbase-assertion" xlink:to="rels" order="1.0"
      name="rels" />

    <!-- general variable is sequence of weighted children values -->
    <variable:generalVariable xlink:type="resource" xlink:label="v_weightedChildValues" bindAsSequence="true"
      select="for $rel in $rels,
                  $to-concept in xfi:relationship-to-concept($rel),
                  $child in $family[node-name(.) eq $to-concept]
              return ($child * xfi:relationship-attribute($rel,QName('','weight')))" />

    <!-- precondition, don't evaluate assertion test if there are no children -->
    <variable:precondition xlink:type="resource" xlink:label="precondition" 
     test="exists($weightedChildValues)" />
    <generic:arc xlink:type="arc" xlink:to="precondition" xlink:from="calc-linkbase-assertion" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set-precondition" />

  </generic:link>

</link:linkbase>
